<?php

namespace app\shop\model\company;

use think\Model;
use app\shop\model\shop\User;
use think\model\concern\SoftDelete;
/**
 * 应用模型
 */
class CompanyFile extends Model
{
    use SoftDelete;
    protected $autoWriteTimestamp = true;

    const TYPE_RULE = 1;    //规章制度
    const TYPE_ATTEND = 2;    //考勤文件
    const TYPE_INSURANCE = 3;    //集体险文件

    public function user()
    {
        return $this->belongsTo(User::class, 'handle_user', 'shop_user_id');
    }

    public function getTypeTextAttr($value, $data)
    {
        switch ($data['file_type']) {
            case self::TYPE_RULE:
                return '规章制度';
            case self::TYPE_ATTEND:
                return '考勤文件';
            case self::TYPE_INSURANCE:
                return '集体险文件';
            default:
                return '其他文件';
        }
    }
}